package BVRClient;

/**
 * The Blue vs Red: Arena Point Class.
 * @author Jesse Gill
 * @author Shannon Setter
 */
public class BVRC_Point
{
	public float x = 0.0f;
	public float y = 0.0f;
	
	/**
	 * 
	 */
	public BVRC_Point() {}
	
	/**
	 * 
	 * @param x
	 * @param y
	 */
	public BVRC_Point(int x, int y)
	{
		this.x = x;
		this.y = y;
	}
	
	/**
	 * 
	 * @param x
	 * @param y
	 */
	public BVRC_Point(float x, float y)
	{
		this.x = x;
		this.y = y;
	}
	
	/**
	 * 
	 * @param p
	 * @return the distance from the given point
	 */
	public double distanceFromPoint(BVRC_Point p)
	{
		try
		{
			return Math.sqrt(Math.pow((p.x - this.x), 2) + Math.pow((p.y - this.y), 2));
		}
		catch (Exception e)
		{
			e.printStackTrace();
			
			return 0;
		}
	}
	
	/**
	 * 
	 * @param r
	 * @return true if there is a collision, false if not
	 */
	public boolean rectCollision(BVRC_Rect r)
	{
		return r.pointCollision(this);
	}
}
